<?php

/**
 * ExtScriptFileBase class file
 *
 * @author TrueSoftware B.V. (The Netherlands)
 * @link http://www.ext4yii.com
 * @copyright Copyright 2007-2010 TrueSoftwareB.V. all rights reserved.
 * @license http://www.ext4yii.com/license/
 *          EVALUATION VERSION - NOT FOR COMMERCIAL USE OR DISTRIBUTION.
 * @version 0.7.2
 */
class ExtScriptBlockBase extends ExtWidget
{

    //override
    public function parseNode(ExtHTMLParserNode $node, ExtASTWalker $astwalker)
    {
        //remove the current attributes
        $node->attr = array();
        $script = $this->parseScriptProperty('body', null, $node, $astwalker);
        $position = strtolower(trim($this->getPosition()));
        $position = $position == '' ? 'head' : $position;
        if ($position == 'inline')
        {
            $node->outertext = sprintf("<script type=\"text/javascript\">\n/*<![CDATA[*/\n%s\n/*]]>*/\n</script>",$script);
        }
        else
        {
            if ($position == 'head')
                $position = CClientScript::POS_HEAD;
            else if ($position == 'end')
                $position = CClientScript::POS_END;
            else if ($position == 'begin')
                $position = CClientScript::POS_BEGIN;

            Yii::app()->getClientScript()->registerScript($this->getID(), $script, $position);
            $node->shiftUp();
            $node->outertext = '';
        }
    }

    //override
    public function createContainer(ExtHTMLParserNode $node)
    {
        return null;
    }

    //override
    public function renderConfig($asobject = true)
    {
        return null;
    }

}

?>
